package com.imooc.miaosha.rabbitmq;

import com.imooc.miaosha.util.BeanUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MqSender {
    private final static Logger logger = LoggerFactory.getLogger(MqSender.class);
    @Autowired
    AmqpTemplate amqpTemplate;

    public void send(Object message){
        logger.info("send message:{}",message);
        amqpTemplate.convertAndSend(MqConfig.QUEUE , BeanUtil.beanToString(message));
    }
}
